/*
 * To Check format of user request
 */
package GUI;

import java.awt.List;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Bui Thi Mai
 */
public class UIFormat {
    
    /**
     * Check Date format (dd/MM/yyyy)
     * @param date
     * @return 
     */
    public static Boolean validDate(Date date){
        return false;
    }
    
    public static Boolean validDate(String dateToValidate, String dateFromat){
        if(dateToValidate == null){
			return false;
		}
 
		SimpleDateFormat sdf = new SimpleDateFormat(dateFromat);
		sdf.setLenient(false);
 
		try {
 
			//if not valid, it will throw ParseException
			Date date = sdf.parse(dateToValidate);
			System.out.println(date);
 
		} catch (ParseException e) {
 
			e.printStackTrace();
			return false;
		}
 
		return true;
    }
    
    /**
     * Check mail format
     * @param mail
     * @return 
     */
    public static Boolean validMail(String mail){
        Pattern pattern = Pattern.compile(MyConst.MailParttern);
        Matcher matcher = pattern.matcher(mail);
        return matcher.matches();
    }
    
    /**
     * check Name format
     * @param name
     * @return 
     */
    public static Boolean validName(String name){
        String USERNAME_PATTERN = MyConst.NameParttern;
        Pattern pattern;
        Matcher matcher;
        pattern = Pattern.compile(USERNAME_PATTERN);
        matcher = pattern.matcher(name);
        return matcher.matches();
    }
    
    /**
     * check PhoneNumber format
     * @param phone
     * @return 
     */
    public static Boolean validPhoneNumber(String phone){
        Pattern pattern = Pattern.compile(MyConst.PhoneNumberParttern);
        Matcher matcher = pattern.matcher(phone);
        return matcher.matches();
    }
    
    /**
     * Check String length Max
     * @param s
     * @param lenMax
     * @return 
     */
    public static Boolean validStringLengthMax(String s, int lenMax){
        if(s.length() <= lenMax){
            return true;
        }
        return false;
    }
    
    /**
     * Check String length Min
     * @param s
     * @param LengthMin
     * @return 
     */
    public static Boolean validStringLengthMin(String s,int LengthMin){
        if(s.length() > LengthMin){
            return true;
        }
        
        return false;
    }
    
    
}
